package com.atshiyou.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(value = "/logout")
public class LogOutServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        //接收用户的退出登录请求
        System.out.println("--执行退出-登录请求--");
        req.getSession().invalidate();
        PrintWriter printWriter = resp.getWriter();
        printWriter.write("<script>alert('退出登录成功，点击确定回到登录界面');location.href='./index.jsp'</script>");
    }


}
